<?php
	$type = $_FILES["files"]["type"];
	$extension_name;
	switch($type){
	   case 'image/pjpeg':$extension_name='.jpg';
	   break;
	   case 'image/jpeg':$extension_name='.jpg';
	break;
	   case 'image/gif':$extension_name='.gif';
	   break;
	   case 'image/png':$extension_name='.png';
	   break;
	   case 'image/x-png':$extension_name='.png';
	   break;
	   case 'image/bmp':$extension_name='.bmp';
	   break;
	}
if ($_FILES["files"]["size"] < 1024 * 1024){
	$filename = com_create_guid().$extension_name;
	$whole_path = dirname(__FILE__).'/upload/'.$filename;
	move_uploaded_file($_FILES["files"]["tmp_name"],$whole_path);
	echo "<script>parent.uploadFinished('http://localhost/eaters-website/upload/".$filename."');parent.alert('上传成功');</script>";
}else{
	echo "<script>parent.alert('上传文件出错或者类型错误！');</script>";
}

	
?>